def resultats(cube,clusters):
	#generation du fichier de resultats
	file=open("resultats_clusterisation.txt","w")
	listeExceptions=[]
	listeLignes=[]	
	i=0
	for c in clusters:
		if len(c)==1:
			#liste des exceptions
			listeExceptions.append(cube["proteine"]["id_proteine"][c[0]])
			
		elif len(c)!=1:
			#analyse des clusters
			dict={"id": [], "hydrophobes": [999999,-99999], "taille":[999999,-99999],"pI":[999999,-99999], "nb_chaines":[999999,-99999]}
			i=i+1
			
			for indice in c:
				dict['id'].append(cube["proteine"]["id_proteine"][indice])
				if dict["hydrophobes"][0]>float(cube["proprietes"]['AA_hydrophobes'][indice]) :
					dict["hydrophobes"][0]=float(cube["proprietes"]['AA_hydrophobes'][indice])
					
				if dict["hydrophobes"][1]<float(cube["proprietes"]['AA_hydrophobes'][indice]) :
					dict["hydrophobes"][1]=float(cube["proprietes"]['AA_hydrophobes'][indice])
					
				if dict["taille"][0]>float(cube["proteine"]['longueur'][indice]) :
					dict["taille"][0]=float(cube["proteine"]['longueur'][indice])
					
				if dict["taille"][1]<float(cube["proteine"]['longueur'][indice]) :
					dict["taille"][1]=float(cube["proteine"]['longueur'][indice])
				
				if dict["pI"][0]>float(cube["proprietes"]['pI'][indice]) :
					dict["pI"][0]=float(cube["proprietes"]['pI'][indice])
					
				if dict["pI"][1]<float(cube["proprietes"]['pI'][indice]) :
					dict["pI"][1]=float(cube["proprietes"]['pI'][indice])
					
				if dict["nb_chaines"][0]>float(cube["proteine"]['nb_chaines'][indice]) :
					dict["nb_chaines"][0]=float(cube["proteine"]['nb_chaines'][indice])

				if dict["nb_chaines"][1]<float(cube["proteine"]['nb_chaines'][indice]) :
					dict["nb_chaines"][1]=float(cube["proteine"]['nb_chaines'][indice])
					
			listeLignes.append("Cluster numero " + str(i) +":( "+ str(dict["hydrophobes"][0])+" < % AA_hydrophobes < "+str(dict["hydrophobes"][1])+", "+ str(dict["taille"][0])+" < longueur < "+str(dict["taille"][1] )+", "+str(dict["pI"][0])+ " < pI < "+ str(dict["pI"][1])+" , "+str(dict["nb_chaines"][0]) + " < nb_chaines < " +str(dict["nb_chaines"][1] )+ ") \n")
			listeLignes.append("Ce cluster contient "+ str(len(dict['id']))+" proteines.\n")
			for id in dict['id']:
				listeLignes.append("\t"+id +'\n')
			listeLignes.append('\n')
	
		
	file.write("La clusterisation a forme " + str(len(clusters) - len(listeExceptions))+ " groupes de proteines. \n\n" )
	
	
	file.write("Les "+str(len(listeExceptions))+ " exceptions sont :\n ")
	
	
	
	
	for e in listeExceptions:
		file.write("\t"+e+ "\n")
	file.write("\n\n" )
	for l in listeLignes :
		file.write(l )

	file.close()
		
			